public class Thread4
{
	public static void main(String args[])
	{
		MyThread1 mt1 = new MyThread1("first");
		MyThread2 mt2 = new MyThread2("first");
		MyThread3 mt3 = new MyThread3("first");

		mt1.start();
		mt2.start();
		mt3.start();
	}
}

class MyThread1 extends Thread
{
	String name;
	MyThread1(String threadname)
	{
		name = threadname;
	}

	public void run()
	{
		try
		{
			for(int i=0;i<5;i++)
			{
				System.out.println(name+":"+i);
				Thread.sleep(1000);
			}
		}
		catch(Exception e)
		{
			System.out.println(name+"Exception");
		}
		System.out.println(name+"quit");
	}
}

class MyThread2 extends Thread
{
	String name;
	MyThread2(String threadname)
	{
		name = threadname;
	}

	public void run()
	{
		try
		{
			for(int i=0;i<5;i++)
			{
				System.out.println(name+":"+i);
				Thread.sleep(1000);
			}
		}
		catch(Exception e)
		{
			System.out.println(name+"Exception");
		}
		System.out.println(name+"quit");
	}
}
class MyThread3 extends Thread
{
	String name;
	MyThread3(String threadname)
	{
		name = threadname;
	}

	public void run()
	{
		try
		{
			for(int i=0;i<5;i++)
			{
				System.out.println(name+":"+i);
				Thread.sleep(1000);
			}
		}
		catch(Exception e)
		{
			System.out.println(name+"Exception");
		}
		System.out.println(name+"quit");
	}
}
